<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WVP启停流控制工具</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <link href="/static/css/styles.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/socket.io-client@4.7.2/dist/socket.io.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.19.0/js/md5.min.js"></script>
</head>

<body>
    <a href="/" class="btn btn-outline-light home-btn">
        <i class="bi bi-house-door"></i> 首页
    </a>
    <div class="container-fluid">
        <div class="row header text-center">
            <div class="col-12">
                <h3><i class="bi bi-play-btn me-2"></i>WVP启停流控制工具</h3>
                <p class="text-white">支持设备循环启停流操作</p>
            </div>
        </div>

        <div class="main-content">
            <div class="row equal-height">
                <!-- 左侧控制面板 -->
                <div class="col-lg-6">
                    <div class="card" id="leftCard">
                        <div class="card-header">
                            <i class="bi bi-sliders me-2"></i>WVP启停流设置
                        </div>
                        <div class="card-body">
                            <div class="setting-group">
                                <h5 class="sub-panel-title"><i class="bi bi-gear me-2"></i>基本设置</h5>
                                <div class="mb-3">
                                    <label class="form-label">域名</label>
                                    <input type="text" class="form-control form-input" id="domain"
                                        placeholder="例如：https://wvp.example.com" value="https://wvp.soft.cowarobot.com">
                                    <p class="small text-muted mb-0">支持手动输入域名</p>
                                </div>
                                <form>
                                    <div class="row mb-3">
                                        <div class="col-md-6">
                                            <label class="form-label">用户名</label>
                                            <input type="text" class="form-control form-input" id="username"
                                                placeholder="请输入用户名" value="admin">
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label">密码</label>
                                            <div class="position-relative">
                                                <input type="password" class="form-control form-input" id="password"
                                                    placeholder="请输入密码" value="Cowa@2024#">
                                                <i class="bi bi-eye position-absolute top-50 end-0 translate-middle-y me-3 cursor-pointer"
                                                    id="togglePassword" style="z-index: 10;"></i>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                                <div class="mb-3">
                                    <label class="form-label">设备ID列表</label>
                                    <textarea class="form-control form-input" id="deviceIds" rows="3"
                                        placeholder="多个设备ID用逗号或换行进行分隔">44030700001320000390,44030700001320000350,44030700001320000360</textarea>
                                </div>

                                <div class="row mb-3">
                                    <div class="col-md-6">
                                        <label class="form-label">最大循环次数</label>
                                        <input type="number" class="form-control" id="maxLoops" min="1" value="100">
                                    </div>
                                    <div class="col-md-6">
                                        <label class="form-label">检测间隔(秒)</label>
                                        <input type="number" class="form-control" id="checkInterval" min="1" value="5">
                                    </div>
                                </div>



                                <div class="mb-3">
                                    <label class="form-label">媒体检测URL</label>
                                    <input type="text" class="form-control" id="mediaCheckUrl"
                                        value="https://media10.media.cowarobot.com/index/api/getMediaList?secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc">
                                </div>

                                <div class="status-container">
                                    <div>
                                        <span>运行状态:</span>
                                        <span id="wvpStatus" class="ms-2">
                                            <span class="status-indicator status-inactive"></span>
                                            <span>未运行</span>
                                        </span>
                                    </div>
                                    <button id="startBtn" class="btn btn-success">
                                        <i class="bi bi-play-circle me-2"></i>开始测试
                                    </button>
                                </div>
                            </div>

                            <div class="setting-group mt-4">
                                <h5 class="sub-panel-title"><i class="bi bi-graph-up me-2"></i>统计信息</h5>
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="stat-card">
                                            <div class="stat-value" id="totalLoops">0</div>
                                            <div class="stat-label">总循环次数</div>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="stat-card">
                                            <div class="stat-value" id="successCount">0</div>
                                            <div class="stat-label">成功次数</div>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="stat-card">
                                            <div class="stat-value" id="failureCount">0</div>
                                            <div class="stat-label">失败次数</div>
                                        </div>
                                    </div>
                                </div>
                                <div class="mt-3">
                                    <div class="progress" style="height: 10px;">
                                        <div class="progress-bar bg-success" id="successRateBar" role="progressbar"
                                            style="width: 0%"></div>
                                    </div>
                                    <div class="text-center small mt-1" id="successRateText">成功率: 0%</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 右侧日志输出区域 -->
                <div class="col-lg-6">
                    <div class="card" id="rightCard">
                        <div class="card-header d-flex justify-content-between align-items-center">
                            <div>
                                <i class="bi bi-journal-text me-2"></i>运行日志
                            </div>
                            <div>
                                <button id="clearLogBtn" class="btn btn-sm btn-outline-danger me-1">
                                    <i class="bi bi-trash me-1"></i>清空
                                </button>
                            </div>
                        </div>
                        <div class="card-body p-0">
                            <div class="log-container" id="logContainer"></div>
                            <button id="scrollToBottomBtn" class="scroll-to-bottom active" title="自动滚动">
                                <i class="bi bi-arrow-down-circle"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/static/js/wvp_media_control.js"></script>
</body>

</html>